<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/pages/common/header.jsp"%>
<jdf:themeFile file="business/order${template}.js" />
</head>
<c:choose>
    <c:when test="${action=='unpay'}">
        <c:set value="应收款订单" var="title"/> 
    </c:when>
    <c:when test="${action=='my'}">
        <c:set value="我的订单" var="title"/> 
    </c:when>
    <c:when test="${action=='audit'}">
        <c:set value="订单审核" var="title"/> 
    </c:when>
    <c:when test="${action=='page'}">
        <c:set value="订单管理" var="title"/> 
    </c:when>
    <c:when test="${action=='paid'}">
        <c:set value="已收款订单" var="title"/> 
    </c:when>
    <c:otherwise>
        <c:set value="订单查询" var="title"/> 
    </c:otherwise>
</c:choose>
<body>
	<div class="contentBody contentborder">
		<div class="tab-pane" id="tabPane">
			<div id="message">${message }</div>
			<div class="tab-page">
				 <h1 class="tab">${title}</h1>
 				 <div class="contentborder">
                	 <jdf:form bean="request" scope="request">
						<form action="${dynamicDomain}/order/${action}" method="post">
							 <table class="inputTable">
			                 	<tr>
									<td nowrap class="label cancelBorderLeft">
										<label for="search_EQI_objectId">订单编号：</label>
									</td>
									<td class="content">
										<input type="text" name="search_EQI_objectId" />
									</td>
									<td nowrap class="label">
										<label for="search_GED_orderDate">订单日期：</label>
									</td>
									<td class="content">
										<input type="text" id="search_GED_orderDate" size="14" name="search_GED_orderDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'search_LED_orderDate\')}',readOnly:true})">
										~
									    <input type="text" id="search_LED_orderDate" size="14" name="search_LED_orderDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'search_GED_orderDate\')}',readOnly:true})">
									</td>
			                 	</tr>
			                 	<c:if test="${action!='unpay'&&action!='paid' }">
			                 	<tr>
                                    <td nowrap class="label cancelBorderLeft">
                                        <label for="search_EQI_status">状态：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <select name="search_EQI_status">
                                            <option value=""></option>
                                            <jdf:select dictionaryId="1001" valid="true"/>
                                        </select>
                                    </td>
                                    
                                </tr>
                                </c:if>
                                <c:if test="${action=='unpay' }">
                                <tr>
                                    <td nowrap class="label cancelBorderLeft">
                                        <label for="search_GED_predictPayDate">应付日期：</label>
                                    </td>
                                    <td class="content">
                                       <input type="text" id="search_GED_predictPayDate" size="12" name="search_GED_predictPayDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'search_LED_predictPayDate\')}',readOnly:true})">
                                        ~
                                        <input type="text" id="search_LED_predictPayDate" size="12" name="search_LED_predictPayDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'search_GED_predictPayDate\')}',readOnly:true})">
                                    </td>
                                    <td nowrap class="label">
                                        <label for="search_LIKES_clientPo">客人订单编号：</label>
                                    </td>
                                    <td class="content">
                                       <input type="text" name="search_LIKES_clientPo">
                                    </td>
                                </tr>
                                </c:if>
                                <tr>
                                    <td nowrap class="label cancelBorderLeft">
                                        <label for="search_EQI_currency">币种：</label>
                                    </td>
                                    <td class="content">
                                        <select name="search_EQI_currency">
                                            <option value=""></option>
                                            <jdf:select dictionaryId="1006" valid="true"/>
                                        </select>
                                    </td>
                                    <td nowrap class="label">
                                        <label for="search_EQI_customerId">客户：</label>
                                    </td>
                                    <td class="content">
                                        <input type="hidden" name="search_EQI_customerId" id="customerId"/>
                                        <input type="text" name="customerName" id="customerName"/>
                                        <a href="${dynamicDomain}/customer/select?ajax=1&action=${action}" class="colorbox">选择客户</a>
                                    </td>
                                </tr>
			                 	<tr>
                                	<td class="bottomLabel" nowrap colspan="4">
                                		<div class="right">
											<button type="reset">重置</button>
											<button type="submit">查询</button>
                                		</div>
									</td>
								</tr>
			                 </table>
			            </form>
			        </jdf:form>
				</div>
				<div class="contentborder listArea">
					<div class="toolBar">
						<c:if test="${action=='my'||action=='page'}">
		 				<button type="button" onclick="window.location.href='${dynamicDomain}/order/create?action=${action}'">增加</button>
		 				</c:if>
					</div>
					<div id="tableDiv">
						<jdf:table items="items" var="currentRowObject" retrieveRowsCallback="limit" filterRowsCallback="limit" sortRowsCallback="limit" action="${action}">
							<jdf:export view="csv" fileName="订单.csv" tooltip="Export CSV" imageName="csv" />
							<jdf:export view="xls" fileName="订单.xls" tooltip="Export EXCEL" imageName="xls" />
							<jdf:row>
								<jdf:column property="objectId" title="订单编号" style="width: 10%">
								    ${currentRowObject.orderNo}
								</jdf:column>
								<jdf:column property="customerId" title="客户" style="width: 15%">
                                  <jdf:columnCollectionValue items="customers"  nameProperty="name" value="${currentRowObject.customerId}"/>(${currentRowObject.customerNo})
                                </jdf:column>
                                <jdf:column property="1" title="客户" style="width: 15%" viewsDenied="html">
                                    ${currentRowObject.customerNo}
                                </jdf:column>
								<jdf:column property="orderDate" title="订单日期" style="width: 9%" cell="date"/>
								<c:if test="${action=='unpay' }">
								<jdf:column property="predictPayDate" title="应付日期" style="width: 10%" cell="date"/>
								</c:if>
								<c:if test="${action=='paid' }">
                                <jdf:column property="payDate" title="付款日期" style="width: 5%" cell="date"/>
                                </c:if>
								<jdf:column property="clientPo" title="客人订单编号" style="width: 7%"/>
								<jdf:column property="currency" title="币种" style="width: 5%" viewsDenied="html">
                                    <jdf:columnValue dictionaryId="1006" value="${currentRowObject.currency}"/>
                                </jdf:column>
                                <c:if test="${action!='unpay'&&action!='paid' }">
								<jdf:column property="status" title="状态" style="width: 5%">
									<jdf:columnValue dictionaryId="1001" value="${currentRowObject.status}"/>
								</jdf:column>
								</c:if>
								<jdf:column property="salesId" title="销售员" style="width: 5%">
									<jdf:columnCollectionValue items="users" nameProperty="userName" value="${currentRowObject.salesId}"/>
								</jdf:column>
								<jdf:column alias="操作" sortable="false" viewsAllowed="html" style="width: 15%">
								   <c:choose>
								       <c:when test="${currentRowObject.status<20 ||action=='page'}">
								           <c:if test="${(action=='my' && s_userId==currentRowObject.salesId)||action=='page'}">
								           <a href="${dynamicDomain}/order/edit/${currentRowObject.id}?action=${action}" class="button">修改</a>
								           </c:if>
								       </c:when>
								   </c:choose>
									<a href="${dynamicDomain}/order/print/${currentRowObject.objectId}?action=${action}" class="button">查看</a>
									<c:if test="${action=='audit' }">
									   <a href="javascript:audit(${currentRowObject.objectId},'${action}')" class="button audit" title="订单审核通过后就不能修改了">审核通过</a>
									</c:if>
									
									<c:if test="${(action=='page'||action=='audit') &&currentRowObject.status < 50 }">
                                       <a href="#backwardReason" onclick="javascript:currentOrderId=${currentRowObject.objectId};" class="button audit backward">退回</a>
                                    </c:if>
									<c:if test="${(currentRowObject.status == 20 && action=='audit')||action=='page'}">
									   <a href="#selectUser" onclick="javascript:currentOrderId=${currentRowObject.objectId};getCustomer(${currentRowObject.customerId});" class="button audit edit">邮件通知</a>
									</c:if>
									<c:if test="${action=='unpay' }">
									   <a href="javascript:pay(${currentRowObject.objectId},'${action}')" class="button audit">收款</a>
									</c:if>
									<c:if test="${action=='page'&&currentRowObject.status!=90  }">
									   <a href="javascript:finish(${currentRowObject.objectId},'${action}')" class="button audit">定单完成</a>
									</c:if>
									<a href="${dynamicDomain}/order/download/${currentRowObject.objectId}" class="button">PDF下载</a>
								</jdf:column>
							</jdf:row>
						</jdf:table>
					</div>
				</div>
			</div>
		</div>
	</div>
	   
	<div style="display: none;">
	    <div id="selectUser" class="contentborder">
	        <div id="suberror"></div>
	        <div id="subnotice"></div>
	        <table class="inputTable">
	           <tr>
	               <td class="label cancelBorderLeft" style="width: 20%;"><label>客户：</label></td>
	               <td class="content">&nbsp;<input type="checkbox" name="customer" value="1" id="customer_1" style="vertical-align: middle;">&nbsp;<label id="customer_2" for="customer_1"></label></td>
	           </tr>
	           <jsp:include page="/extendUser/selectEmailUsers" flush="true" />
	           <tr>
	               <td class="bottomLabel" colspan="2">
                      <div class="right">
                          <button onclick="notify()" id="notifyButton">邮件通知</button>
                      </div>
                  </td>
	           </tr>
	        </table>
	    </div>
    </div>
    
    <div style="display: none;">
        <div id="backwardReason" class="contentborder">
            <div id="suberror1" class="suberror"></div>
            <div id="subnotice1" class="subnotice"></div>
            <table class="inputTable">
               <tr>
                   <td class="label cancelBorderLeft" style="width: 25%;"><label>退回原因：</label></td>
                   <td class="content">&nbsp;<textarea cols="30" rows="2" name="reason" id="reason"></textarea></td>
               </tr>
                <tr>
                   <td class="bottomLabel" colspan="2">
                      <div class="right">
                          <button onclick="backward('${action}')" id="backwardButton">确认退回</button>
                      </div>
                  </td>
               </tr>
            </table>
        </div>
    </div>
    
	<script type="text/javascript">
		
		$(function() {
	        $(".colorbox").colorbox({iframe:true, innerWidth:700, innerHeight:460});
	        $(".backward").colorbox({inline:true, innerWidth:400, innerHeight:200,href:'#backwardReason'});
		    $('.edit').colorbox({ inline:true,innerWidth:500, innerHeight:300,href:'#selectUser'});
		});
		
		var currentOrderId = null;
		
	</script>
</body>
</html>